// Schema loader - 加载各问卷 JSON 配置
import screeningData from '@/static/questionnaire/screening.json'
import assessConfig from '@/static/questionnaire/assess_config.json'
import assessResult from '@/static/questionnaire/results/assess_result.json'
import healthtestConfig from '@/static/questionnaire/healthtest_config.json'
import a1_cognitionData from '@/static/questionnaire/assessment/a1_cognition.json'
import a2_movementData from '@/static/questionnaire/assessment/a2_movement.json'
import a3_nutritionData from '@/static/questionnaire/assessment/a3_nutrition.json'
import a4_visionData from '@/static/questionnaire/assessment/a4_vision.json'
import a5_hearingData from '@/static/questionnaire/assessment/a5_hearing.json'
import a6_emotionData from '@/static/questionnaire/assessment/a6_emotion.json'
import h1_importantEffectData from '@/static/questionnaire/healthtest/h1_important_effect.json'
import h2_dangerousEffectData from '@/static/questionnaire/healthtest/h2_dangerous_effect.json'

const questionnaires = {
    screening: screeningData,
    a1_cognition: a1_cognitionData,
    a2_movement: a2_movementData,
    a3_nutrition: a3_nutritionData,
    a4_vision: a4_visionData,
    a5_hearing: a5_hearingData,
    a6_emotion: a6_emotionData,
    h1_important_effect: h1_importantEffectData,
    h2_dangerous_effect: h2_dangerousEffectData
}

/**
 * 获取问卷定义
 * @param {string} quesName - 问卷名
 * @returns {Object} 问卷定义
 */
export const getQuestionnaire = (quesName) => {
    if (quesName === 'assessment') {
        return { config: assessConfig, resultSchema: assessResult };
    }
    return questionnaires[quesName];
}

export const getSubQuestionnaire = (type, id) => {
    if (type === 'assessment') {
        const quesName = assessConfig.detail.find((d) => d.id === id)?.name;
        return questionnaires[quesName];
    }
    return null;
}

/**
 * 获取所有问卷配置
 * @returns {Object} 所有问卷配置
 */
export const getAllQuestionnaires = () => {
    return questionnaires;
}

/**
 * 获取评估配置
 * @returns {Object} 评估配置
 */
export const getAssessConfig = () => {
    return assessConfig;
}

/**
 * 获取评估结果配置
 * @returns {Object} 评估结果配置
 */
export const getAssessResult = () => {
    return assessResult;
}

/**
 * 获取健康测试配置
 * @returns {Object} 健康测试配置
 */
export const getHealthtestConfig = () => {
    return healthtestConfig;
}
